package top.yuhaitao.cloud.hystrix;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import feign.hystrix.FallbackFactory;
import top.yuhaitao.cloud.entity.User;
import top.yuhaitao.cloud.feign.UserFeignClient;
import top.yuhaitao.cloud.feign.UserFeignClientFactory;

@Component
public class HystrixClientFactoryFallback implements FallbackFactory<UserFeignClient> {

	private static final Logger log = LoggerFactory.getLogger(HystrixClientFactoryFallback.class);

	@Override
	public UserFeignClient create(Throwable arg0) {
		log.info("HystrixClientFactoryFallback-UserFeignClientFactory:{}", "init..................");

		return new UserFeignClientFactory() {

			@Override
			public User postUser(User user) {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public User getUserById2(Long id) {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public User getUserById(Long id) {
				User user = new User();
				user.setId(0L);
				user.setName("feign hystix factory");
				return user;
			}

			@Override
			public User getUser(User user) {
				// TODO Auto-generated method stub
				return null;
			}
		};
	}

}
